from time import sleep,time
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.wait import WebDriverWait

# driver=webdriver.Chrome()
#
# 6、浏览器导航
# driver.get("https://www.baidu.com/")
# driver.find_element(By.CSS_SELECTOR,"#chat-textarea").send_keys("你好")
# driver.find_element(By.CSS_SELECTOR,"#chat-submit-button").click()
# sleep(1)
# ## 浏览器后退
# driver.back()
# sleep(2)
# ## 浏览器前进
# driver.forward()
# sleep(2)
# ## 浏览器刷新
# driver.refresh()
# sleep(2)

# 7、文件上传
# driver.get("file:///E:/source/learn/SET-AutoTest/LearnAutoTest/upload.html")
# # 选择输入框ID并输入上传文件的绝对路径
# driver.find_element(By.ID,"fileInput").send_keys("E:\\source\\learn\\SET-AutoTest\\LearnAutoTest\\test.txt")
# sleep(3)

# driver.quit()

# 8、浏览器参数设置
# ## 无头模式-不会打开界面
# option=webdriver.ChromeOptions()
# option.add_argument("--headless")
# driver=webdriver.Chrome(options=option)
# driver.get("https://www.baidu.com/")
# driver.quit()

## 页面加载策略
# 浏览器参数配置，添加页面加载策略
options = webdriver.ChromeOptions()
# options.page_load_strategy = 'normal' # 等待所有的资源加载完成
options.page_load_strategy = 'eager'  # DOM访问就绪，多数选择这个
# options.page_load_strategy = 'none'     # 完全不阻塞，直接继续往下执行脚本，大多数会报错
# 创建谷歌浏览器驱动对象
driver=webdriver.Chrome(options=options)
driver.get("https://haokan.baidu.com/")
print(driver.title)
driver.quit()